<!-- Modal -->
<div class="modal fade " id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="box box-info">
            <div class="box-header with-border">
                <h3 class="box-title">添加信用卡</h3>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form id="addContactForm" class="form-horizontal">
                <div class="box-body">
                    <div class="form-group">
                        <label for="inputEmail3" class="col-sm-2 control-label">姓名</label>
                        <div class="col-sm-7">
                            <select></select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputPassword3" class="col-sm-2 control-label">性别</label>
                        <div id="sexDiv" class="radio col-sm-6">
                            <label>
                                <input type="radio" name="conSex" value="1" checked>
                                男
                            </label>
                            <label>&nbsp;</label>
                            <label>
                                <input type="radio" name="conSex" value="2">女
                            </label>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputEmail3" class="col-sm-2 control-label">所属供应商</label>
                        <div class="col-sm-7">
                            <select id="conSupplierId" class="form-control " name="conSupplierId">
                                <#if suppliers??>
                                    <#list suppliers as vo>
                                        <option value="${vo.supId}">${vo.supName}</option>
                                    </#list>
                                </#if>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputEmail3" class="col-sm-2 control-label">职位</label>
                        <div class="col-sm-7">
                            <select id="conProfession" class="form-control" name="conProfession">
                                <option value="1">销售</option>
                                <option value="2">实施</option>
                                <option value="3">开发</option>
                                <option value="4">售前</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputPassword3" class="col-sm-2 control-label">座机</label>

                        <div class="col-sm-7">
                            <input type="text" class="form-control" id="conTel" name="conTel">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputPassword3" class="col-sm-2 control-label">手机</label>

                        <div class="col-sm-7">
                            <input type="number" class="form-control" id="conMobileNo" name="conMobileNo">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputPassword3" class="col-sm-2 control-label">邮箱</label>

                        <div class="col-sm-7">
                            <input type="email" class="form-control" id="conEmail" name="conEmail">
                        </div>
                    </div>
                </div>
                <!-- /.box-body -->
                <div class="box-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary pull-right" onclick="contactAdd()">添加</button>
                </div>
                <!-- /.box-footer -->
            </form>
        </div>
    </div>
</div>
<script>
    function contactAdd() {

        var conName = $("#conName").val();
        var conSex = $('#sexDiv input[name="conSex"]:checked ').val();
        var conProfession = $("#conProfession").val();
        var conTel = $("#conTel").val();
        var conMobileNo = $("#conMobileNo").val();
        var conEmail = $("#conEmail").val();
        var conSupplierId = $("#conSupplierId").val();
        var data = {
            conName: conName,
            conSex: conSex,
            conProfession: conProfession,
            conTel: conTel,
            conMobileNo: conMobileNo,
            conEmail: conEmail,
            conSupplierId: conSupplierId
        };
        var url = "/contact/addcontact";
        $.ajax({
            type: 'POST',
            url: url,
            dataType: "json",
            data: JSON.stringify(data),
            contentType: "application/json; charset=utf-8",
            success: function(result){
                if(result.success){
                    $('#myModal').modal('hide') ;
                    $('#addContactForm')[0].reset();
                    searchInfo();
                } else {
                    alert(result.msg);
                }
            }
        });
    }

</script>
